function MEMORY()
{

    this.init = function (size)
    {
	this.size = size;
	this.mem = new Array (size);
    };

    this.reset = function ()
    {
	var i;
	for(i=0;i<this.size;i++)
	{
	    this.mem[i]=0;	    
	}
    };

    this.write= function (addr,val)
    {
	this.mem[addr]=val;
    };
    
    this.read= function (addr)
    {
	return (this.mem[addr]);
    };

    this.write_blob = function (addr,blob,len)
    {
	var i;
	var up = addr+len;
	var max = this.size;
	if(up>max) {
	    up=max;
	};
	var iter = up-addr;
	for(i=0;i<iter;i++)
	{
	 this.mem[addr+i]=blob[i];
	};
    };

    this.read_blob = function (addr,len)
    {
	var max = this.size;
	if(addr+len>max)
	{
	    return (this.mem.slice(addr));
	} else {
	    return (this.mem.slice(addr,addr+len-1));
	};
    };
    

    this.dump= function ()
    {
	
    };
    
}